package com.mxpio.crm.contract.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 合同对象 crm_contract
 *
 * @author Cheng
 * @date 2022-11-24
 */
@Data
@Entity
@Table(name = "crm_contract")
@Schema(description = "合同表")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class CrmContract extends BaseEntity {
    /**
     * 主键
     */
    @Id
    @Generator
    @Schema(description = "主键")
    @Column(name = "id", length = 64)
    private String id;
    /**
     * 合同名称
     */
    @Schema(description = "合同名称")
    @Column(name = "name", length = 50)
    private String name;
    /**
     * 合同编号
     */
    @Schema(description = "合同编号")
    @Column(name = "num", length = 255)
    private String num;
    /**
     * 客户ID
     */
    @Schema(description = "客户ID")
    @Column(name = "customer_id", length = 64)
    private String customerId;
    /**
     * 客户名称
     */
    @Schema(description = "客户名称")
    @Column(name = "customer_name", length = 255)
    private String customerName;
    /**
     * 商机ID
     */
    @Schema(description = "商机ID")
    @Column(name = "business_id", length = 64)
    private String businessId;
    /**
     * 销售机会
     */
    @Schema(description = "销售机会")
    @Column(name = "sale_chance", length = 128)
    private String saleChance;
    /**
     * 业务类型
     */
    @Schema(description = "业务类型")
    @Column(name = "business_type", length = 16)
    @Dict(dicCode = "business_type")
    private String businessType;
    /**
     * 合同总价
     */
    @Schema(description = "合同总价")
    @Column(name = "money")
    private BigDecimal money;
    /**
     * 整单折扣
     */
    @Schema(description = "整单折扣")
    @Column(name = "discount_rate")
    private BigDecimal discountRate;
    /**
     * 签订日期
     */
    @Schema(description = "签订日期")
    @Column(name = "order_date")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date orderDate;
    /**
     * 是否开票
     */
    @Schema(description = "是否开票")
    @Column(name = "billed", length = 16)
    @Dict(dicCode = "MB_SYSTEM_YES_NO")
    private String billed;
    /**
     * 负责人ID
     */
    @Schema(description = "负责人ID")
    @Column(name = "owner_user_id", length = 64)
    private String ownerUserId;

    /**
     * 批次 比如附件批次
     */
    @Schema(description = "批次 比如附件批次")
    @Column(name = "batch_id", length = 64)
    private String batchId;
    /**
     * 备注
     */
    @Schema(description = "备注")
    @Column(name = "remark", length = 255)
    private String remark;
    /**
     * 所属公司
     */
    @Schema(description = "所属公司")
    @Column(name = "company")
    private String company;
    /**
     * 客户所有人
     */
    @Schema(description = "客户所有人")
    @Column(name = "owner_customer", length = 64)
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String ownerCustomer;
    /**
     * 状态
     */
    @Schema(description = "状态")
    @Column(name = "check_status", length = 16)
    @Dict(dicCode = "contract_check_status")
    private String checkStatus;
}
